package priv.pfz.sbv;

import lombok.Data;

import java.util.regex.Pattern;

/**
 * @author yyjxp
 * 2024/2/16 3:06
 */
@Data
public class BeanCategory {
    /**
     * 默认分组
     */
    public static final BeanCategory DEFAULT_CATEGORY = new BeanCategory("default", "");

    /**
     * 分组名称
     */
    private String categoryName;

    /**
     * beanName的正则表达式，用于判断是否分到本分组
     */
    private Pattern beanNamePattern;

    public BeanCategory(String categoryName, String beanNameRegex) {
        this.categoryName = categoryName;
        this.beanNamePattern = Pattern.compile(beanNameRegex);
    }

    public boolean match(String beanName) {
        return beanNamePattern.matcher(beanName).matches();
    }
}
